package vn.edu.saigontech.ncms.model.bookstore;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;

import org.hibernate.annotations.OptimisticLockType;

import vn.edu.saigontech.ncms.model.BaseEntity;

@Entity
@org.hibernate.annotations.Entity(dynamicInsert = true, dynamicUpdate = true, optimisticLock = OptimisticLockType.ALL)
@Table(name = "ncms_bookstore_item_type")
@SuppressWarnings("serial")
public class ItemType extends BaseEntity implements Comparable<ItemType> {
	
	public static final String SB = "Student Book";
	public static final String WB = "Work Book";
	public static final String CD = "CD";
	
	@Column(name = "name", nullable = false, unique = true)
	private String name;
	
	@Column(name = "item_unit")
	private String unit;

	@Column(name = "sequence")
	private int order;

	public ItemType() {
	}

	public ItemType(String name, int order) {
		this.name = name;
		this.order = order;
	}
	
	@Override
	public int compareTo(ItemType that) {
		return this.order - that.order;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getOrder() {
		return order;
	}

	public void setOrder(int order) {
		this.order = order;
	}

	public String getUnit() {
		return unit;
	}

	public void setUnit(String unit) {
		this.unit = unit;
	}
}